<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>函数闭包的应用</title>
</head>
<body>
    
    <script>
        
        -function () {

            function fn () {
                let ary = [];

                return function () {
                    for (let i = 0;i < arguments.length;i ++) {
                        ary.push(arguments[i]);
                    }
                    return ary;
                }
            } 

            let gn = fn ();
            console.log(gn (1,2,3,4,5));
        } ();

        -function () {

            function cost () {
                let ary = [];
                
                return function () {
                    if (arguments.length === 0) {
                        return 
                    }
                }
            }

        } ();

        {
            function b () {

                let a = 100;

                return function () {
                    return a + 200;
                }
            }

            let a  = b();

            console.log('a',a());

        }

    </script>
</body>
</html>